 using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Crystal.Mapping;

namespace Crystal.Libs
{
    public static class Resources
    {
        //Color Textures        
        public static Dictionary<string, Effect> FxLibaray;

        public static Dictionary<int, Model> CellFloorModels;
        public static Dictionary<int, Texture2D> ContainerFloorMaps;
        
        public static Texture2D WallMap;
        public static Model CellWallModel;   
        
        //METHODS        
        public static void LoadData(Game game)
        {
            //Load in the Effects
            FxLibaray= new Dictionary<string, Effect>();            
            FxLibaray.Add("Container", game.Content.Load<Effect>("gfx/container"));
            
            //Load in the Wall Stuff
            WallMap = game.Content.Load<Texture2D>("graphics/uv/wall126_uvmap");
            CellWallModel = LoadModel(game, FxLibaray["Container"], "assets/container_wall126");
            
            //Load in the Floor Models 
            CellFloorModels = new Dictionary<int, Model>();
            CellFloorModels.Add(0, LoadModel(game, FxLibaray["Container"], "assets/container_floor$1"));
                     
            //& Textures                
            ContainerFloorMaps = new Dictionary<int, Texture2D>();
            ContainerFloorMaps.Add(0, game.Content.Load<Texture2D>("graphics/uv/container_floor$1"));
        }

        public static Model LoadModel(Game game, Effect fx, string assetName)
        {
            Model newModel = game.Content.Load<Model>(assetName);

            foreach (ModelMesh mesh in newModel.Meshes)
                foreach (ModelMeshPart meshPart in mesh.MeshParts)
                    meshPart.Effect = fx.Clone();

            return newModel;
        }
    }
}
